﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zzva.Common;


namespace Zzva.Report
{

    // Описывает поле - значение
    public class TReportFieldValue: TReportFieldBase 
    {

        private bool mvarTotalSum;
        private bool mvarRotate90;
        private float mvarColumnWidth;
        private byte mvarFontSize;
        private string mvarNumberFormat;
        private int mvarColumnExcel;

        private int mvarNumberInTraversal;



        public override TReportFieldBase GetField(string pOboznFull)
        {
            try
            {
                int lPozFirstPoint;

                lPozFirstPoint = pOboznFull.IndexOf('.');

                if (lPozFirstPoint == -1)
                {
                    if (pOboznFull == Obozn) { return this; }
                    else { throw (new CommonException("Поле не найдено")); }
                }
                else
                {throw (new CommonException("Ошибка поиска поля"));}



            }

            catch (Exception e1) { throw e1; }
            finally { }
        }




        public override int GetColFieldValue()
        {
            return 1;
        }






        public override int GetColLevel()
        {
            return 0;
        }




        public int NumberInTraversal
        {
           get { return mvarNumberInTraversal;}
           set{mvarNumberInTraversal = value;}
        }





        public bool TotalSum
        {
            get { return mvarTotalSum; }
            set { mvarTotalSum = value; }
        }



        public bool Rotate90
        {
            get { return mvarRotate90; }
            set { mvarRotate90 = value; }
        }



        public float ColumnWidth
        {
            get { return mvarColumnWidth; }
            set { mvarColumnWidth = value; }
        }


        public  byte  FontSize
        {
           get{return mvarFontSize;}
           set{mvarColumnExcel  = value;}
        }



        public  string  NumberFormat
        {
           get{return mvarNumberFormat;}
           set
           {
               if (value == "") { mvarNumberFormat = "General"; }
               else{mvarNumberFormat  = value;}
               //Здесь можно еще сделать проверку Преобрауется ли строка в десятичное число
           }
        }




        public  int ColumnExcel
        {
           get{return mvarColumnExcel;}
           set{mvarColumnExcel  = value;}
        }





        public TReportFieldValue(string pObozn,string pOboznFull, string pNaim,
            bool  pTotalSum, bool pRotate90, float pColumnWidth,
            byte pFontSize, string pNumberFormat)
            : base(pObozn, pOboznFull, pNaim)
        {


            mvarNumberInTraversal = 0;


            mvarTotalSum = pTotalSum;
            mvarRotate90 = pRotate90;
            mvarColumnWidth = pColumnWidth;
            mvarFontSize = pFontSize;

            ////mvarNumberFormat = pNumberFormat;
            if (pNumberFormat == "") { mvarNumberFormat = "General"; }
            else { mvarNumberFormat = pNumberFormat; }



        }








    }
}
